﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using jSLApp.Client.Wpf.Forms;
using jSLCore.Client.Presentation.BaseControl;
using jSLCore.Client.Presentation.BaseControl.Advanced;
using jSLCore.Client.Presentation.BaseControl.DialogMessage;
using jSLCore.Client.Presentation.BaseControl.Selection;
using jSLCore.Client.Presentation.jBinding;

namespace jSLApp.Client.Wpf
{
    /// <summary>
    /// Interaction logic for DefaultPage.xaml
    /// </summary>
    public partial class DefaultPage : DataControl
    {
        public DefaultPage()
        {
            InitializeComponent();
        }

        private void showInfo_Clicked(object sender, RoutedEventArgs e)
        {
            InfoBox.ShowDialog("InfoDialog. Autoclose on 2 seconds",2000,this);
        }

        private void showShowError(object sender, GenericEventArgs<object> e)
        {
            e.Parameter = "Rhis binding get the value from the method in the from. Click here.";
        }

        private void showError_Clicked(object sender, EventArgs e)
        {
            ErrorBox.ShowDialog("This is ErrorDialog",this);
        }

        public override void LoadInitialData()
        {
            Bind();
        }

        private void show_AppContainer(object sender, RoutedEventArgs e)
        {
            new MainWindow().Show();
        }

        private void showSelect_Clicked(object sender, RoutedEventArgs e)
        {
            new StringList(){SelectionMode = GridSelectionMode.MultiRow}.ShowDialog(delegate(object o, IEnumerable<object>
                                                                                        data)
                                                                                        {
                                                                                            foreach (var d in data)
                                                                                            {
                                                                                                InfoBox.ShowDialog((string) d,this);
                                                                                            }
                                                                                        }, this );
        }

        private void goTeleric_Clicked(object sender, RoutedEventArgs e)
        {
            new TelForm().ShowDialog(this);
        }

        private void showSelect2_Clicked(object sender, RoutedEventArgs e)
        {
            new TreeList(){SelectionMode = GridSelectionMode.SingleRow}.ShowDialog(delegate(object o, object data)
                                                                                       {
                                                                                           InfoBox.ShowDialog(((node)data).Name,this);
                                                                                       }, this);
        }

        private void dotheWork_Clicked(object sender, RoutedEventArgs e)
        {
            DoWork("Выполняется работа",(o, args) =>
                                            {
                                                Thread.Sleep(3000);
                                            },(sender1, eventArgs) =>
                                                             {
                                                                 //InfoBox.ShowDialog("Done",700,this);
                                                             });
        }
    }
}
